﻿<#macro imgUpload action>
<script type="text/javascript">
//上传图片
function upload(n) {
	var of = $('#uploadFile'+n);
	//检查是否选择了图片
	if(of.val()=='') {
		alert('请选择要上传的图片!');
		return;
	}
	if(!checkImg(of.val())){
		alert('请上传图片!');
		return;
	}
	
	$('#uploadFile_span'+n).block({
        message: '<img src="${base}/images/admin/loading2.gif" />'
    });
	
	//将file移动至上传表单
	$('#fileContent').empty();
	$('#fileContent').append(of);
	//复制一个file放至原处
	$('#ufc'+n).append(of.clone());
	//修改属性
	of.attr('id','');
	of.attr('name','uploadFile');
	$('#uploadNum').val(n);
	
	$('#uploadForm').submit();
}

function checkImg(img){
	var strFilter=".jpeg|.gif|.jpg|.png|.bmp|";
	if(img.indexOf(".")>-1){
        var strPostfix=img.substring(img.lastIndexOf("."),img.length) + '|';        
        var strPostfix = strPostfix.toLowerCase();
        if(strFilter.indexOf(strPostfix)>-1){
            return true;
        }
    }       
    return false; 
}
	
</script>
<form id="uploadForm" action="${action}" method="post" enctype="multipart/form-data" target="hiddenIframe" style="display:none;width:0px;height:0px;">
<span id="fileContent"></span>
<input id="uploadNum" type="hidden" name="uploadNum"/>
<input type="hidden" id="uploadRuleId" name="uploadRuleId" value="${uploadRuleId}"/>
</form>
<iframe name="hiddenIframe" frameborder="0" border="0" style="display:none;width:0px;height:0px;"></iframe>
</#macro>